package com.dylon.system.domain;

import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Date;
import java.util.List;

@Data
public class SysUsers extends BaseEntity {
    private static final long serialVersionUID = 1L;

    private Long   userId;
    private String account; //'账号',
    private String userName; //'名称',
    private String passWord; //'密码',
    private String userType; //'用户类型，00系统用户',
    private String email; //'邮箱',
    private String phone; //'手机号码',
    private String sex;   //'性别，0男，1女，2其他',
    private String photo; //'头像路径',
    private String salt;  //'盐加密',
    private String status; //'状态，0正常，1禁用',
    private String loginIp;   //'最后登入IP',
    private Date   loginDate; //'最后登入时间',

    private Long   deptId;  //'所属部门',
    private Long   parentDeptId; //部门父节点

    private SysDepartment dept;

    private List<SysRole> roles;

    /** 角色组 */
    private Long[] roleIds;


    public boolean isAdmin()
    {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(Long userId)
    {
        return userId != null && 1L == userId;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("userId", getUserId())
                .append("account", getAccount())
                .append("userName", getUserName())
                .append("email", getEmail())
                .append("phone", getPhone())
                .append("sex", getSex())
                .append("photo", getPhoto())
                .append("passWord", getPassWord())
                .append("salt", getSalt())
                .append("status", getStatus())
                .append("deptId", getDeptId())
                .append("loginIp", getLoginIp())
                .append("loginDate", getLoginDate())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .append("remark", getRemark())
                .append("dept", getDept())
                .toString();
    }
}
